package org.example.event;

import lombok.Getter;

import java.util.EventObject;

@Getter
public class MyEvent extends EventObject {

    private final Object data;

    public MyEvent(MyEventSource source, Object data) {
        super(source);
        this.data = data;
    }

    @Override
    public String toString() {
        return "MyEvent{" +
                "source=" + getSourceName() +
                ", data=" + data +
                '}';
    }

    private String getSourceName() {
        return ((MyEventSource) getSource()).getName();
    }
}
